package me.a01immutable;

import java.util.Iterator;
import java.util.Set;

public class ImmutableDemo2 {
    public static void main(String[] args) {
        //创建不可变的Set集合
        Set<String> set = Set.of("zhangsan", "lisi", "wangwu");
        for (String name : set) {
            System.out.println(name);
        }
        System.out.println("----------------------");

        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            String s = it.next();
            System.out.println(s);
        }
    }
}
